package org.boyan.common.util.jsonschema.validate;

import com.alibaba.fastjson.JSONObject;
import java.util.HashMap;
import java.util.Map;
import org.boyan.common.util.jsonschema.CommonProperty;

/**
 * @author: zhuxiaobao
 * @time: 2021/9/24 16:04
 */

public class TreeSelectProperty extends CommonProperty {
    private static final long l = 3786503639885610767L;

    private String m;

    private String n;

    private String o;

    private String p;

    private String q;

    private Integer r = Integer.valueOf(0);

    public String getDict() {
        return this.m;
    }

    public void setDict(String dict) {
        this.m = dict;
    }

    public String getPidField() {
        return this.n;
    }

    public void setPidField(String pidField) {
        this.n = pidField;
    }

    public String getPidValue() {
        return this.o;
    }

    public void setPidValue(String pidValue) {
        this.o = pidValue;
    }

    public String getHasChildField() {
        return this.p;
    }

    public void setHasChildField(String hasChildField) {
        this.p = hasChildField;
    }

    public TreeSelectProperty() {}

    public String getTextField() {
        return this.q;
    }

    public void setTextField(String textField) {
        this.q = textField;
    }

    public Integer getPidComponent() {
        return this.r;
    }

    public void setPidComponent(Integer pidComponent) {
        this.r = pidComponent;
    }

    public TreeSelectProperty(String key, String title, String dict, String pidField, String pidValue) {
        this.b = "string";
        this.e = "sel_tree";
        this.a = key;
        this.f = title;
        this.m = dict;
        this.n = pidField;
        this.o = pidValue;
    }

    public TreeSelectProperty(String key, String title, String pidValue) {
        this.b = "string";
        this.e = "cat_tree";
        this.a = key;
        this.f = title;
        this.o = pidValue;
    }

    public TreeSelectProperty(String key, String title, String pidValue, String textField) {
        this(key, title, pidValue);
        this.q = textField;
    }

    @Override
    public Map<String, Object> getPropertyJson() {
        HashMap<Object, Object> hashMap = new HashMap<>();
        hashMap.put("key", getKey());
        JSONObject jSONObject = getCommonJson();
        if (this.m != null) {
            jSONObject.put("dict", this.m);
        }
        if (this.n != null) {
            jSONObject.put("pidField", this.n);
        }
        if (this.o != null) {
            jSONObject.put("pidValue", this.o);
        }
        if (this.q != null) {
            jSONObject.put("textField", this.q);
        }
        if (this.p != null) {
            jSONObject.put("hasChildField", this.p);
        }
        if (this.r != null) {
            jSONObject.put("pidComponent", this.r);
        }
        hashMap.put("prop", jSONObject);
        return (Map)hashMap;
    }
}
